home *** CD-ROM | disk | FTP | other *** search
- Path: dawn.mmm.com!news
- From: kjhopps@mmm.com (Kevin J Hopps)
- Newsgroups: comp.lang.c++
- Subject: Re: realloc() -- is there a method for this in c++
- Date: 8 Mar 1996 13:40:00 GMT
- Organization: 3M - St. Paul, MN 55144-1000 US
- Message-ID: <4hpdbg$k1d@dawn.mmm.com>
- References: <4hm5mg$lgl@calvin.cs.ucsb.edu>
- Reply-To: kjhopps@mmm.com
- X-Newsreader: TIN [version 1.2 PL2]
-
- Hyun J. Kim (kimhy@cs.ucsb.edu) wrote:
- > Hi,
-
- > I am trying to change the size of an array dynamically. In C, using realloc()
- > this is possible. However, in C++, I am not sure if this is possible using
- > the new operator. If you have any insight to this problem, please drop me an
- > e-mail.
-
- There is no equivalent of realloc in C++ (except realloc itself, of
- course :-). The only safe way to resize an array is to allocate a new
- one, copy and delete the old.
-
- Unless you're trying to implement one, you could use an array class --
- these objects can resize themselves as necessary, managing the memory
- for you.
- --
- Kevin J. Hopps e-mail: kjhopps@mmm.com
- 3M Company phone: (612) 737-4643
- 3M Center, Bldg. 235-2D-57 fax: (612) 737-2700
- St. Paul, MN 55144-1000 Opinions are my own. I don't speak for 3M.
- But 3M speaks for me -- I did not write the following line:
-
- Opinions expressed herein are my own and may not represent those of 3M.
-